﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MicroDb.SqlServer
{
    class SqlServerResolveTable : SqlServerResolveBase
    {
        public SqlServerResolveTable(Type type, SqlExecute sqlExecute) : base(sqlExecute)
        {
            this.TableType = type;
        }

        /// <summary>
        /// 复制为新的表
        /// </summary>
        /// <param name="newTableName"></param>
        /// <param name="withData"></param>
        public void CopyToNewTable(string newTableName, bool withData)
        {
            string tabName = GetTabName();
            string sql = $"CREATE TABLE {newTableName} LIKE {tabName}; ";
            if (withData)
            {
                sql += $"INSERT INTO {newTableName}  SELECT * FROM {tabName};";
            }
            sqlExecute.ExecuteNonQuery(System.Data.CommandType.Text, sql, null);
        }



        public override object GetResult()
        {
            throw new NotImplementedException();
        }
    }
}
